

package com.moonstar.exception;


import com.moonstar.pojo.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理器
 *
 * @author
 */
@RestControllerAdvice
public class MyExceptionHandler {
	private Logger logger = LoggerFactory.getLogger(getClass());

	@ExceptionHandler(AuthException.class)
	public Result handleAuthException(AuthException e){
		logger.error(e.getMessage(), e);
		return Result.error(e.getCode(), e.getMsg());
	}

	@ExceptionHandler(Exception.class)
	public Result handleException(Exception e){
		logger.error(e.getMessage(), e);
		return Result.error("系统异常");
	}
}
